package Thread;

class MyThread extends Thread{
    @Override
    public void run() {
        while (true) {
            System.out.println("hello thread.");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }

        }
    }
}

public class Demo1 {
    // Thread 的常见构造方法
    public static void main(String[] args) {

        Thread t = new MyThread();
        t.start();
        //t.run(); // 没有创建新线程，只是在之前的内容里执行了 run里面的内容

        while (true) {
            System.out.println("hello main.");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
